#ifndef GLOBALPARAM_H
#define GLOBALPARAM_H

#include "TableWidgetForm.h"

struct paramstruct
{
    QString name;
    int val;
    QString unit;
    QString des;
    int edit;
    QString type;
    int uplimit;
    int lowlimit;

    // 获取结构体成员名的字符串
    QString toFieldNames() const {
        return QString("name,val,unit,des,edit,type,uplimit,lowlimit");
    }

    // 获取结构体成员名的字符串
    QStringList toFieldTypes() const {
        QStringList _list;
        _list << typeid(name).name();
        _list << typeid(val).name();
        _list << typeid(unit).name();
        _list << typeid(des).name();
        _list << typeid(edit).name();
        _list << typeid(type).name();
        _list << typeid(uplimit).name();
        _list << typeid(lowlimit).name();
        return _list;
    }
};

class GlobalParam
{
public:
    GlobalParam();

    //初始化UI
    static void InitUI(const QString& fileName, QList<QPair<QWidget *, QString>>& widgets, QMap<int, QList<TableWidgetForm*>>& m_pTableWidgetFormMap);

    //保存
    static bool SaveUI(const QString& fileName, const QMap<int, QList<TableWidgetForm*>>& m_pTableWidgetFormMap);

    //解析
    static void Analysis(const QString& path, QList<paramstruct>& paramstructList);

    //保存
    static bool SaveXml(const QString& path, const QList<paramstruct>& paramstructList);
};

#endif // GLOBALPARAM_H
